//
//  ViewController.m
//  refresh
//
//  Created by 张雪东 on 15/9/24.
//  Copyright (c) 2015年 张雪东. All rights reserved.
//

#import "ViewController.h"
#import "RefreshView.h"

#define KSCREENTSIZE [UIScreen mainScreen].bounds.size

@interface ViewController ()

@property (nonatomic,strong) RefreshView * refresh;

@end

@implementation ViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    
    UITableView * tableView = [[UITableView alloc] initWithFrame:CGRectMake(0, 0,KSCREENTSIZE.width , KSCREENTSIZE.height)];
    NSLog(@"%@",NSStringFromCGRect(tableView.frame));
    UIImage * image = [UIImage imageNamed:@"dabai-1"];
    UIImageView * imageView = [[UIImageView alloc] initWithFrame:CGRectMake(0, 0, KSCREENTSIZE.width, image.size.height)];
    imageView.image = image;
    tableView.tableHeaderView = imageView;
    [self.view addSubview:tableView];
    _refresh = [[RefreshView alloc] initInScrollView:tableView];
    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(loadMore:) name:@"loading" object:nil];
}


-(void)loadMore:(NSNotification *)notification{

    double delayInSeconds = 3.0;
    dispatch_time_t popTime = dispatch_time(DISPATCH_TIME_NOW, delayInSeconds * NSEC_PER_SEC);
    dispatch_after(popTime, dispatch_get_main_queue(), ^(void){
        [_refresh endRefreshing];
    });
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

@end
